package Generic;

class Alg {
//泛型方法
    public static <T extends Comparable<T>>T func(T[] array) {

        T t = array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i].compareTo(t) > 0) {
                t = array[i];
            }

        }
        return t;
    }
    }


class Generic<T extends Number>{//泛型边界约束


    Object[] object=new Object[10];

    public void setArray(int pos,T val){

        object[pos]=val;
    }

    public T getArray(int pos){
        return (T)object[pos];
    }
}
public class Test {
    public static void main(String[] args) {
        String str="asddf";
        String str1="ddf";
        int num=str.indexOf(str1);
        System.out.println(num);
        char[] ch=new char[]{1,4,7};

    }

    public static void main2(String[] args) {
        Integer[] integer={1,2};
        Integer i= Alg.func(integer);
        System.out.println(i);
    }

    public  static void main1(String[] args) {


        Alg alg=new Alg();
        Integer[] integer = new Integer[]{1, 2};

        System.out.println(alg.<Integer>func(integer));


    }


    }

